<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>svg直线</title>
</head>

<body>
    <svg height="210" width="500">
        <line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
    </svg>
    <div>
        x1属性定义了直线的x轴起始坐标<br/>
        y1属性定义了直线的y轴起始坐标<br/>
        x2属性定义了直线的x轴终止坐标<br/>
        y2属性定义了直线的y轴终止坐标
    </div>
</body>
<script>
    var svg = document.querySelector('svg');
    var line = svg.querySelector('line');
    line.style.stroke = '#000'
</script>

</html>